#include <ut/UnitTest.h>
#include <illib/Log.h>
#include <ilrt/String.h>

using namespace ilrt;

namespace ilrt_ut{
	void String_ut() {
		ut::UnitTestLogger logger(TN(illib_ut::String_ut));
		Allocator::PoolAllocator<illib::RedBlackTree::Node<StringCache::Entry> > allocator(0, "Test");
		StringCache::Cache cache;
		String & string1 = cache.add(allocator, "yo dude");
		String & string2 = cache.add(allocator, "yo dude1");
		String & string3 = cache.add(allocator, "yo dude2");
		ut::test(AT(), EX((&string1 != &string2) && (&string2 != &string3) && (&string3 != &string1)), TN(StringCache::cache));
		String * string4 = cache.get("yo dude");
		ut::test(AT(), EX(&string1 == string4), TN(StringCache::cache));
		cache.clear();
	}
};
